package com.fg.cloud.factory.controller.product;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.druid.util.StringUtils;
import com.fg.cloud.framework.controller.BaseController;
import com.fg.cloud.manager.entry.product.ProductSkuEntity;
import com.fg.cloud.manager.service.product.ProductSkuService;

/**
  * <p>Description:</p>
  * @author liushengchao
  * @date 2017年7月31日下午4:13:43
 */
@Controller
@RequestMapping(value="/sku")
public class ProudctSkuController extends BaseController{

	@Autowired
	private ProductSkuService skuService ;
	
	/**
	  * Description:新增商品详情信息（规格参数）
	  * @param req
	  * @param resp
	  * @param sku 商品详情信息
	  * @author liushengchao
	  * @date 2017年7月31日下午4:19:24
	 */
	@RequestMapping(value="/insert",method={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public void insert(HttpServletRequest req , HttpServletResponse resp , ProductSkuEntity sku) {
		try {
			if(sku == null || StringUtils.isEmpty(sku.getProductName())){
				doResult(resp, false, 713, null, "商品详情信息输入有误");
			}else{
				int result = 0 ;
				result = skuService.insert(sku) ;
				if(result==0){
					doResult(resp, false, 722, null, "保存信息失败");
				}else{
					doResult(resp, true, 721, null, "保存信息成功");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
